<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        #canvas{
            background-color:gray;
        }
        /* #canvas{
            width:400px;
            height:400px;
            background-color: gray;
        } */
    </style>
  </head>
  <body>
    <canvas id="canvas" width="400px" height="300px"></canvas>wdt
    <!-- 开发时使用行间样式设置width和height而不使用CSS -->
    <!-- <canvas id="canvas"></canvas>wdt -->
  </body>
  <script>
    var canvas = document.querySelector("#canvas");
    // 渲染上下文
    var cts = canvas.getContext("2d");
    //2d表示绘制的是2d图形，webgl表示绘制的是3d图形
    console.log(cts);
  </script>
</html>
